package com.promise.jokerdream.ui.webview

/**
 * WebViewCallback的默认实现
 * 提供基本的回调处理逻辑
 */
class WebViewCallbackImpl(
    private val onPageFinished: (String) -> Unit,
    private val onProgressChanged: (Int) -> Unit,
    private val onLoginDetected: ((String, String, String) -> Unit)? = null,
    private val onFightProcessProgress: ((Int, Int) -> Unit)? = null,
    private val onFightProcessCompleted: (() -> Unit)? = null,
    private val onFightProcessCancelled: (() -> Unit)? = null
) : IWebViewCallback {
    
    override fun onPageFinished(url: String) {
        onPageFinished.invoke(url)
    }
    
    override fun onProgressChanged(progress: Int) {
        onProgressChanged.invoke(progress)
    }
    
    override fun onLoginDetected(userId: String, username: String, cookie: String) {
        onLoginDetected?.invoke(userId, username, cookie)
    }
    
    override fun onFightProcessProgress(currentPage: Int, totalPages: Int) {
        onFightProcessProgress?.invoke(currentPage, totalPages)
    }
    
    override fun onFightProcessCompleted() {
        onFightProcessCompleted?.invoke()
    }
    
    override fun onFightProcessCancelled() {
        onFightProcessCancelled?.invoke()
    }
}